<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

//在这里定义接口路由
$api = app(\Dingo\Api\Routing\Router::class);


#默认配置指定的是v1版本，可以直接通过 {host}/api/version 访问到
$api->version('v1',['namespace' => 'App\Http\Controllers\Api'], function ($api) {
//    $api->group(['middleware' => 'api.throttle', 'limit' => 2, 'expires' => 1],
//        function ($api) {
//获取轮播图接口
    $api->get('slider', 'SliderController@slider');
    //获取所有文章接口
    $api->get('articles', 'ArticleController@articles');
    //获取推荐文章接口
    $api->get('hotArticle', 'ArticleController@hotArticle');
    //获取单个文章接口
    $api->get('article/{id}', 'ArticleController@article');
    //获取所有分类数据接口
    $api->get('categorys', 'CategoryController@categorys');
    //小程序登录接口
    $api->post('login', 'AuthController@login');
    //小程序退出登录接口
    $api->get('logout', 'AuthController@logout');
    //获取已经登录的用户信息接口
    $api->get('me', 'AuthController@me');
//        });

});
//接口的v2版本
//$api->version('v2', function ($api) {
//    $api->get('version', function () {
//        return 'v2';
//    });
//});



